<template>
	<view style="padding: 30rpx;">
		<view style="" class="u-flex" style="justify-content: space-between;" v-for="(item,index) in bookItemArr" :key="index"
		@click="browseClick(item.id)" >
			<view style="position: relative;">
				<image :src="$url+item.imageUrl" mode="aspectFill"
				style="width: 160rpx;height: 240rpx;border-radius: 0.5em;"></image>
				<text style="position: absolute;right: 10rpx;top: 10rpx;background-color: #635A5B;
				color: #FFFFFF;padding: 5rpx;">{{item.state}}</text>
			</view>
			<view style="font-size: 30rpx;padding: 15rpx 0;flex: 1;">
				<view style="padding:20rpx;">{{item.name}}</view>
				<view style="padding:20rpx;color: #999999;">书封页</view>
				<view style="padding:20rpx;">{{item.looktime | formatDate}}</view>
			</view>
			<view style="font-weight: bold; font-size: 36rpx;color: #e46e41;padding: 20rpx 30rpx;border-radius: 2em;">
				<text>{{item.score}}分</text>
			</view>
		</view>
		<view v-if="bookItemArr.length ==0" style="text-align: center;padding: 50rpx 0;color: #82848A;">暂无浏览记录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bookItemArr:[],
				datas:[]
			}
		},
		methods: {
			getBrowse(){
				this.bookItemArr = uni.getStorageSync("bookItemArr")
				console.log(this.bookItemArr)
			},
			browseClick(e){
				console.log(e)
				uni.navigateTo({
					url:"../../index/bookItem/bookItem?id="+e
				})
			}
		},
		onLoad() {
			this.getBrowse()
		},
		filters: {
		  numFilter (value) {
		    // 截取当前数据到小数点后两位
		    let realVal = parseFloat(value).toFixed(2)
		    return realVal
		  },
		  formatDate(value) {
		  	if(value == undefined){
		  		return;
		  	}
		  	// let date = new Date(value * 1000);
		  	let date = new Date(value);
		  	//时间戳为10位需*1000，时间戳为13位的话不需乘1000
		  	let y = date.getFullYear();
		  	let MM = date.getMonth() + 1;
		  	MM = MM < 10 ? ('0' + MM) : MM; //月补0
		  	let d = date.getDate();
		  	d = d < 10 ? ('0' + d) : d; //天补0
		  	let h = date.getHours();
		  	h = h < 10 ? ('0' + h) : h; //小时补0
		  	let m = date.getMinutes();
		  	m = m < 10 ? ('0' + m) : m; //分钟补0
		  	let s = date.getSeconds();
		  	s = s < 10 ? ('0' + s) : s; //秒补0
		  	// return y + '-' + MM + '-' + d; //年月日
		  	return y + '-' + MM + '-' + d + ' ' + h + ':' + m+ ':' + s; //年月日时分秒
		  }
		}
	}
</script>

<style>

</style>
